#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int cmp(const void* n1, const void* n2)
{
	return *(int*)n1 - *(int*)n2;
}
int main()
{
	int n = 0;
	int m = 0;
	scanf("%d%d", &n, &m);
	int arr[3005] = { 0 };

	if (m == 0)
	{
		printf("0");
		return 0;
	}

	int i = 0;
	int sum[3005] = { 0 };
	int ps = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
		if (i < m)
		{
			sum[ps] += arr[i];
		}
		else
		{
			ps += 1;
			sum[ps] += (sum[ps - 1] + arr[i] - arr[i - m]);
		}
	}
	qsort(sum, (ps + 1), sizeof(int), cmp);
	printf("%d", sum[0]);
	return 0;
}
